The present invention relates, in general, to traces used within a processing environment, and in particular, to reusing invalidated traces within the processing environment.
A System Virtual Machine (SVM) or Emulator is a piece of software for creating a virtual execution environment. This software allows operating systems and programs written for a particular computation environment (e.g. a processor architecture having an instruction set) to be executed within a different computation environment (e.g. a different processor architecture having another instruction set). An SVM may translate or compile instructions from the emulated architecture (guest architecture) to instructions that are native to the system on which the SVM is being executed (host architecture). This translation can be performed by an interpreter, a just-in-time (JIT) compiler, or by both an interpreter and a JIT.
An SVM that incorporates a JIT compiler chooses sequences of guest instructions that are compiled to native instructions (a semantic routine) and then executed. These sequences of guest instructions are referred to as traces. A single trace may be executed many times. It may be part of a frequently executed program module in the guest operating system (OS) or guest application program, or it may be part of a loop in an emulated program for example. It is therefore worthwhile for the SVM to cache the JIT-compiled native code for the most recently compiled traces. This allows the SVM to reuse the compiled native code without the cost of compilation on future executions of the trace.
Cached native code may correspond to guest instructions in guest memory. If those guest instructions are overwritten then the corresponding cached native code becomes stale. It should not be reused as it no longer reflects the execution state of the guest system. Stale traces may therefore be invalidated (dropped) from the SVM's code cache.